var vm = new Vue({
    el: '#main',
    data: {
        payOff:true,//控制tab栏显示和隐藏
        paymentHasBeenOff:false,//控制tab栏显示和隐藏
        regulationType:0,//调账类型 0 应收 1 应付
        stateHandover:'',//同一弹窗添加个编辑收款用+
        //控制模态框显示和隐藏
        modal:{
            accountRegulateDetailAndEdit:false,//调账详情
            accountRegulateAdd:false,//添加编辑收款
            accountRegulateAudit:false,//付款审核
            payOffTheWindow:false,//付款冲账
            chargeOffDetails:false//已冲账详情
        },
        //调账查询内容
        regulateQueryContent:{
            regulationType:0, //调账类型  0 应收 1 应付
            custType:0,//	（客户类型）  0 签约客户 1 合作商
                       //   （服务商类型）0 官方机构 1合作商
            //difference
            status:'', //	（状态）      0 待提交 1 待审核 2 已审核
            searchKey:'',//搜索关键字
            startDate:'',//搜索开始的日期
            endDate:'',//搜索结束的日期
            current:1,//	当前页码默认为
            pageSize:10,//	每页查询条数默认10条
        },
        regulateEnquiryForm:{
            records: []
        },//(应收)调账页面表单
        regulateEnquiryForm1:{
            records: []
        },//(应付)调账页面表单
        isFirstRenderForm:{
            regulateEnquiryForm: false, //(应收)调账页面表单
            regulateEnquiryForm1: false, //(应付)调账页面表单
        },
        //客户边输入边检索（应收）
        addCollectionContent:{
            custType: 0,//客户类型 0 客户 1 公司
            custName:'',//客户名称
        },
        //客户边输入边检索（应付）
        addCollectionContent1:{
            custType: 0,//服务商类型 0 官方机构 1 合作商
            providerName:'',//服务商名称
        },
        //边输入边检索返回结果（应收付共用）
        customerSearchResult: {
            //后台返回结果
            display: false,
            hasResult: false, //是否查到结果
            content: []
        },
        customerId:[],//匹配客户搜索时的id
        //查询客户（订单编号）应付账单查询
        billContent:{
            custType: 0, //客户类型 0 客户 1 公司
            custName: '', //客户名称
            custId: -1, //客户id
            searchKey: '', //订单编号
        },
        //查询客户（订单编号）应收账单查询
        billContent1:{
            custType: 0, //服务商类型 0 官方机构 1 合作商
            providerName: '', //服务商名称
            providerId: -1, //服务商id
            searchKey: '', //订单编号
        },
        billSearchResult: [], //后台返回账单表单（应收）
        billSearchResult1: [], //后台返回账单表单（应付）
        //调账批量添加
        batchAddAccountRegulation: {
            accountRegulationList: [
                //调账列表
                /*{
                    "orderCode": "013TM17092700015",//订单编号（必须）
                    "billCode":"004YS20171123002",//应收 应付编码（必须）
                    "regulationMoney": 100,//调账金额（必须）
                    "remark": "调账100",//备注 否
                    "status": 0
                }*/
            ],
            custId: -1,//客户id 必须 (应收)
            custName: '',//客户名称 必须 (应收)
            //providerId: -1,//服务商id 必须 (应付)
            //providerName: '',//服务商名称 必须 (应付)
            custType: 1,//客户类型   应收 0客户 1 合作商 应付 0 官方机构 1合作商（ 必须）
            regulationType: 0,//调账类型 0 应收 1 应付（必须）
            status: 0//状态 0 待提交 1 提交 待审核 （必须）
        },
        //详情+编辑获取数据
        handleType: 0, //处理 0 详情  1 编辑
        backHandleData: {}, //(应收)
        backHandleData1: {}, //(应付)
        //调账单条记录编辑上传
        updateStatus: {
            id: -1, //调账id
            regulationMoney: '', //调账金额
            auditRemark: '', //审核备注
            status: 0, //0待提交 1 提交待审核 2 审核
        },
        //审核
        audit:{
            auditRemark: '', //审核备注
            status: -1, //0待提交 1 提交待审核 2 审核
        }
    },
    //计算
    computed:{
        //计算为了监听数组建立的中间对象
        intermediaryObj:function(){
            var self = this;
            var obj = {};
            //计算返回一组新数据格式-->{'0':'xxx','1':'xxx','2':'xxx'}<--[模拟索引号]]
            for(var i = 0;i< self.batchAddAccountRegulation.accountRegulationList.length; i++){
                obj[i] = self.batchAddAccountRegulation.accountRegulationList[i].regulationMoney
            }
            console.log(obj)
            return obj
        },
    },
    //监听
    watch:{
        //为了监听数组建立的中间对象
        'intermediaryObj':{
            handler:function(val,oldVal){
                var self = this;
                for(var i= 0;i<self.batchAddAccountRegulation.accountRegulationList.length;i++){
                    if(oldVal[i]== null){
                        oldVal[i] = 'null'
                    }
                    if(val[i].toString() !== oldVal[i].toString()){
                        self.changeRegulationMoney(i,val[i],oldVal[i])
                    }
                }
            },
            deep: true
        },
        'updateStatus.regulationMoney':function(val,oldVal){
            this.changeRegulationMoney(-1,val,oldVal)
        },
        /*'batchAddAccountRegulation.accountRegulationList':{
            handler:function(val,oldVal){
                console.log(val+' : '+oldVal)
            },
            deep: true
        },*/
        //tab切换状态实时变化
        'regulationType':function(newVal){
            var _this = this;
            _this.regulateQueryContent.regulationType = parseInt(newVal);
            _this.batchAddAccountRegulation.regulationType = parseInt(newVal);
        },
        'addCollectionContent.custName':function(newVal){
            if(newVal == ''){
                this.billContent.custId = -1;
            }
        },
        'addCollectionContent1.providerName':function(newVal){
            if(newVal == ''){
                this.billContent1.providerId = -1;
            }
        },
    },
    //过滤器
    filters: {
        //时间过滤器
        formatDateTime: function(dateStr) {
            if (dateStr == "") {
                return ""
            } else {
                var date = new Date(dateStr);
                return date.getFullYear() + '-' + (date.getMonth() + 1) + '-'
                    + date.getDate();
            }
        },
        //分转元
        changeMoneyUnit:function(money){
            /*Arg Guide
             @ money 金额(分)
             @ return 金额(元)
             */
            var money = parseInt(money);
            var unit = 2;
            return (money / Math.pow(10, unit)).toFixed(2);//保留两位有效数字
        }
    },
    //页面加载之前调用
    created: function () {
        //请求页面列表
        //应收调账初始
        this.regulatePagingMethod()
        this.isFirstRenderForm.regulateEnquiryForm = true;
    },
    // watcher:
    methods: {
        //收款冲账tab栏切换方法
        payOffs: function () {
            this.payOff = true
            this.paymentHasBeenOff = false
            this.regulationType = 0 //调账 应收
        },
        //已冲账tab栏切换方法
        paymentHasBeenOffs: function () {
            this.payOff = false
            this.paymentHasBeenOff = true
            this.regulationType = 1 //调账 应付
            if(!this.isFirstRenderForm.regulateEnquiryForm1){
                this.payClickQuery();
                this.isFirstRenderForm.regulateEnquiryForm1 = true;
            }
        },
        //（应收、应付）调账分页方法
        regulatePagingMethod: function () {
            var _this = this
            VUE_UTIL.getAxiosInstance()
                .get("/finance/erpAccountRegulation/findPage",
                    {
                        params: _this.regulateQueryContent
                    }
                ).then(function (response) {
                    if(_this.regulationType == 0){
                        _this.regulateEnquiryForm = response.data.data;
                        var page_id = 'turn-page';
                      _this.$nextTick(function () {
                        permissonHandler();
                      });
                    }else if(_this.regulationType == 1){
                        _this.regulateEnquiryForm1 = response.data.data;
                        var page_id = 'turn-page1';
                    }
                // 分页
                layui.use(['laypage', 'layer'], function () {
                    var laypage = layui.laypage;
                    laypage({
                        cont: page_id,
                        curr: _this.regulateQueryContent.current || 1,
                        pages: response.data.data.pages,
                        skin: '#457fe6',
                        skip: true,
                        jump: function (obj, first) {
                            if (!first) {
                                _this.regulateQueryContent.current = obj.curr
                                _this.regulateInquiryMethod()
                            }
                        }
                    });
                });
            })
        },
        //搜索栏查询方法
        regulateInquiryMethod: function () {
            if(this.regulationType == 0){
                var collectionKey = 'collectionKey';
                var startTimeCollection = 'startTimeCollection';
                var endCollectionTime = 'endCollectionTime';
                var typesPaymentProviders = 'typesPaymentProviders';
                var collectionStatus = 'collectionStatus';
            }else if(this.regulationType == 1){
                var collectionKey = 'collectionKey1';
                var startTimeCollection = 'startTimeCollection1';
                var endCollectionTime = 'endCollectionTime1';
                var typesPaymentProviders = 'typesPaymentProviders1';
                var collectionStatus = 'collectionStatus1';
            }
            //搜索关键字
            this.regulateQueryContent.searchKey = VUE_UTIL.blankSpace(this.$refs[collectionKey].value)
            //开始时间
            this.regulateQueryContent.startDate = this.$refs[startTimeCollection].value
            //结束时间
            this.regulateQueryContent.endDate = this.$refs[endCollectionTime].value
            //（客户类型）or（服务商类型）
            this.regulateQueryContent.custType = this.dropdownContent(this.$refs[typesPaymentProviders])
            //状态
            this.regulateQueryContent.status = this.dropdownContent(this.$refs[collectionStatus])
            this.regulatePagingMethod()
        },
        //获取下拉框内容
        dropdownContent: function (item) {
            var index = item.selectedIndex
            if (index == -1) {
                index = 0
            }
            if (item.options[index].value == '全部') {
                return ''
            } else {
                return item.options[index].value
            }
        },
        //点击付款冲账查询
        payClickQuery: function () {
            this.regulateQueryContent.current = 1
            this.regulateInquiryMethod()
        },
        //调账表单下拉框显示条数变换事件
        methodName: function () {
            this.regulateQueryContent.pageSize = this.dropdownContent(this.$refs.numberofReceivables)
            this.regulateInquiryMethod()
        },
        //搜索客户变动
        customerSearchChange:function(val){
            var _this = this;
            var params = {}; //传参
            var url = '';  //搜索url
            if(_this.regulationType == 0){
                params = this.addCollectionContent;
                url = '/finance/erpAccountReceivable/findCustGroupList';
            }else if(_this.regulationType == 1){
                params = this.addCollectionContent1;
                url = '/finance/erpBillsPayable/findProviderListByType';
            }else{
            }
            _this.customerSearchResult.hasResult = false; //先设无
            if(val == ''){
                _this.customerSearchResult.display = false;
                _this.customerSearchResult.content = [];
            }else{
                axios.get(url,{
                    params:params
                }).then(function(response){
                    var result = response.data;
                    _this.customerSearchResult.display = true
                    if(result.code == 0){
                        if(result.data.length == 0){
                            //无返回结果时
                            _this.customerSearchResult.hasResult = false;
                            if(_this.regulationType == 0){
                                _this.billContent.custId = -1;
                            }else{
                                _this.billContent1.providerId = -1;
                            }
                        }else{
                            _this.customerSearchResult.hasResult = true;
                        }
                        _this.customerSearchResult.content = result.data;
                    }else{
                        _this.customerSearchResult.hasResult = false;
                        _this.customerSearchResult.content = [{
                            employeeName: '网络错误!'
                        }];
                    }
                })
            }
        },
        //确认所属行业id
        confirmCustomerId:function(item){
            var _this = this;
            if(_this.regulationType == 0){
                _this.billContent.custId = item.custId;
                if(!!_this.customerSearchResult.hasResult){
                    _this.addCollectionContent.custName = item.custName;
                    _this.billContent.custName = item.custName; //放请求参数里
                }
            }else if(_this.regulationType == 1){
                _this.billContent1.providerId = item.providerId;
                if(!!_this.customerSearchResult.hasResult){
                    _this.addCollectionContent1.providerName = item.providerName;
                    _this.billContent1.providerName = item.providerName; //放请求参数里
                }
            }else{}
            _this.customerSearchResult.display = false;
        },
        //客户类型变换的时候
        changingCustomerTypes: function () {
            var _this = this;
            if(_this.regulationType == 0){
                _this.addCollectionContent.custName = '';
                _this.billContent.custType = _this.addCollectionContent.custType;
                //请求参数置位
                _this.billContent.custName = '';
                _this.billContent.custId = -1;
            }else if(_this.regulationType == 1){
                _this.addCollectionContent1.providerName = '';
                _this.billContent1.custType = _this.addCollectionContent1.custType;
                //请求参数置位
                _this.billContent1.providerName = '';
                _this.billContent1.providerId = -1;
            }else{}
            //隐藏结果框
            _this.customerSearchResult.display = false;
        },
        //输入blur
        blurDealResults:function(){
            var _this = this;
            setTimeout(function(){
                _this.customerSearchResult.display = false;
            },200)
        },
        //输入focus
        focusDealResults:function(){
            var _this = this;
            if(_this.regulationType == 0 && _this.addCollectionContent.custName != ''){
                //重新获取搜索结果
                _this.customerSearchChange(_this.addCollectionContent.custName)
                setTimeout(function () {
                    _this.customerSearchResult.display = true;
                },100)
            }else if(_this.regulationType == 1 && _this.addCollectionContent1.providerName != ''){
                //重新获取搜索结果
                _this.customerSearchChange(_this.addCollectionContent1.providerName)
                setTimeout(function () {
                    _this.customerSearchResult.display = true;
                },100)
            }
        },
        //查询客户菜单
        querybill:function(){
            var _this = this;
            //调账类型
            var queryCustomer_url;
            var billContent;
            if(_this.regulationType == 0){
                queryCustomer_url = '/finance/erpAccountReceivable/findAccountReceiveByCustId';  //查询应收客户
                billContent = 'billContent';
                //判断
                if(_this.billContent.custName == '' && _this.billContent.searchKey == ''){
                    layer.msg('请输入订单编号或客户名称',{time:1000})
                    _this.billSearchResult = []; //清空
                    return false;
                }
                if(_this.billContent.custId < 0 && _this.billContent.searchKey == ''){
                    layer.msg('请选择正确的客户名称',{time:1000})
                    return false;
                }
                _this.billContent.custName = _this.addCollectionContent.custName;
            }else if(_this.regulationType == 1){
                queryCustomer_url = '/finance/erpBillsPayable/queryListByProvider';  //查询应付客户
                billContent = 'billContent1';
                //判断
                if(_this.billContent1.providerName == '' && _this.billContent1.searchKey == ''){
                    layer.msg('请输入订单编号或服务商名称',{time:1000})
                    _this.billSearchResult = []; //清空
                    return false;
                }
                if(_this.billContent1.providerId < 0 && _this.billContent1.searchKey == ''){
                    layer.msg('请选择正确的服务商名称',{time:1000})
                    return false;
                }
                _this.billContent1.providerName = _this.addCollectionContent1.providerName;
            }else{
                queryCustomer_url = '';
            }


            //去掉-1的字段
            var param = JSON.parse(JSON.stringify(_this[billContent]));
            for(var i in param){
                if(param.hasOwnProperty(i) && param[i] === -1){
                    delete param[i]
                }
            }

            axios.get(queryCustomer_url,{
                params:param
            }).then(function(response){
                debugger
                    var data = response.data;
                    if(data.code == 0){
                        var billList = data.data;
                        if(_this.regulationType == 0){
                            //应收
                            _this.billSearchResult = billList;
                        }else if(_this.regulationType == 1){
                            //应付
                            _this.billSearchResult1 = billList;
                        }else{}
                        //批量请求参数改动
                        if(billList.length){
                            _this.batchAddAccountRegulation.custId = _this.regulationType == 0 ? billList[0].custId : billList[0].providerId; //客户id
                            _this.batchAddAccountRegulation.custName = _this.regulationType == 0 ? billList[0].custName : billList[0].providerName; //客户名称
                            _this.batchAddAccountRegulation.custType = _this.regulationType == 0 ? billList[0].custType : billList[0].custType; //客户类型
                            _this.batchAddAccountRegulation.accountRegulationList = [];
                            for(var i=0;i<billList.length;i++){
                                _this.batchAddAccountRegulation.accountRegulationList.push({
                                    "orderCode": billList[i].orderCode,//订单编号（必须）
                                    "billCode": billList[i].accountReceivableCode,//应收 应付编码（必须）
                                    "regulationMoney": '0.00',//调账金额（必须）
                                    "remark": '',//备注 否
                                })
                            }
                        }else{
                            layer.msg('未查询到相关数据，或无需进行调账!',{time:1000})
                        }
                    }else{
                        layer.msg(data.msg,{time:1000})
                    }
                })
        },
        //添加调账
        addBill:function(){
            var _this = this;
            _this.modal.accountRegulateAdd=true;
            //置位
            if(_this.regulationType == 0){
                _this.billContent.searchKey = '';
                _this.addCollectionContent.custType = 0;
                _this.addCollectionContent.custName = '';
                _this.billSearchResult = [];
            }else if(_this.regulationType == 1){
                _this.billContent1.searchKey = '';
                _this.addCollectionContent1.custType = 0;
                _this.addCollectionContent1.providerName = '';
                _this.billSearchResult1 = [];
            }else{}
            _this.customerSearchResult.display = false;
        },
        //调账批量添加
        pushUpBatch:function(status){
            var _this = this;
            if(_this.regulationType == 0 && !_this.billSearchResult.length){return} //无数据返回
            if(_this.regulationType == 1 && !_this.billSearchResult1.length){return} //无数据返回
            _this.batchAddAccountRegulation.status = status; //状态 0 待提交 1 提交 待审核

            //检验调账金额是否大于应收余额，是不让保存
            var target_eles = document.getElementsByClassName('addBatchValidate');
            var flag = true;
            for(var i=0;i<target_eles.length;i++){
                if(VUE_UTIL.hasClass(target_eles[i],'error')){
                    layer.msg('调账金额不能大于应收余额',{time:1000})
                    flag = false;
                    break;
                }
            }
            if(!flag){return false}

            //过滤0.00或空的调账
            var result_array = [];
            var target_array = _this.batchAddAccountRegulation.accountRegulationList;
            for(var i=0;i<target_array.length;i++){
                var regulationMoney = parseFloat(target_array[i].regulationMoney);
                if(regulationMoney != 0 && regulationMoney != '' && !isNaN(regulationMoney)){
                    result_array.push(target_array[i])
                }
            }
            if(result_array.length == 0){
                layer.msg('请输入调账金额!',{time:1000})
                return false
            }

            //深拷贝对象
            var copyObj = JSON.parse(JSON.stringify(_this.batchAddAccountRegulation));
            //把过滤后的数组赋上
            copyObj.accountRegulationList = result_array;
            //元转分-S
            for(var i=0;i<copyObj.accountRegulationList.length;i++){
                copyObj.accountRegulationList[i].regulationMoney = copyObj.accountRegulationList[i].regulationMoney * 100;
            }
            //元转分-E
            axios({
                method: 'post',
                url: '/finance/erpAccountRegulation/batchAdd',
                data: JSON.stringify(copyObj),
                headers: {
                    'Content-type': 'application/json'
                }
            }).then(function (response) {
                var data = response.data;
                if (data.code == 0) {
                    var msg = status == 0 ? '保存成功！' : '保存并提交成功！'
                    layer.msg(msg, {time: 1000})
                    _this.regulatePagingMethod()
                } else {
                    layer.msg(data.msg, {time: 1000})
                }
                _this.modal.accountRegulateAdd = false;
            })
        },
        //详情+编辑
        handleModal:function(id,type){
            /**
             * id 调账id
             * type 0: 详情  1: 编辑  2: 审核
             */
            var _this = this;
            var url;
            _this.handleType = type;
            _this.modal.accountRegulateDetailAndEdit=true;
            if(type == 0){
                _this.stateHandover = '调账详情'
            }else if(type == 1){
                _this.stateHandover = '编辑调账'
            } else if(type == 2){
                _this.stateHandover = '调账审核';
                //置位
                _this.audit.auditRemark = '';
                _this.audit.status = -1;
            }
            if(_this.regulationType == 0){
                url = '/finance/erpAccountRegulation/findReceiDetail';
            }else if(_this.regulationType == 1){
                url = '/finance/erpAccountRegulation/findPayRegulationDetail';
            }else{}
            axios.get(url+"?id="+id).then(function(response){
                var data = response.data;
                if(data.code == 0){
                    if(_this.regulationType == 0){
                        _this.backHandleData = data.data;
                        //分转元（要编辑的字段）
                        _this.backHandleData.regulationMoney = (_this.backHandleData.regulationMoney / 100).toFixed(2);
                        //更新编辑提交的字段
                        _this.updateStatus.id = _this.backHandleData.id;
                        _this.updateStatus.regulationMoney = _this.backHandleData.regulationMoney;
                        _this.updateStatus.remark = _this.backHandleData.remark;
                    }else if(_this.regulationType == 1){
                        _this.backHandleData1 = data.data;
                        //分转元（要编辑的字段）
                        _this.backHandleData1.regulationMoney = (_this.backHandleData1.regulationMoney / 100).toFixed(2);
                        //更新编辑提交的字段
                        _this.updateStatus.id = _this.backHandleData1.id;
                        _this.updateStatus.regulationMoney = _this.backHandleData1.regulationMoney;
                        _this.updateStatus.remark = _this.backHandleData1.remark;
                    }else{}
                }
            })
        },
        //调账记录编辑
        commitState:function(status){
            /**
             * status 调账状态  0 待提交 1 提交待审核 2 审核
             */
            var _this = this;
            _this.updateStatus.status = status;
            //检验调账金额是否大于应收余额，是不让保存
            var target_eles = document.getElementsByClassName('editValidate');
            var flag = true;
            for(var i=0;i<target_eles.length;i++){
                if(VUE_UTIL.hasClass(target_eles[i],'error')){
                    layer.msg('调账金额不能大于应收余额',{time:1000})
                    flag = false;
                    break;
                }
            }
            if(!flag){return false}
            //
            if(status == 2){
                if(_this.audit.status < 0){
                    layer.msg('请选择审核结果！',{time:1000})
                    return false
                }
                _this.updateStatus.status = _this.audit.status; //2 通过（审核） 0 驳回（待提交）
                _this.updateStatus.auditRemark = _this.audit.auditRemark; // 审核备注
            }
            //深拷贝对象
            var copyObj = JSON.parse(JSON.stringify(_this.updateStatus));
            //元转分-S
            copyObj.regulationMoney = parseInt(copyObj.regulationMoney*100);
            //元转分-E
            VUE_UTIL.getAxiosInstance().post("/finance/erpAccountRegulation/update",VUE_UTIL.buildPostFormData(copyObj)).then(function(response){
                    var data = response.data;
                    if(data.code == 0){
                        var msg = '';
                        if(status == 0){
                            msg = '保存成功！'
                        }else if(status == 1){
                            msg = '保存并提交成功！'
                        }else if(status == 2){
                            msg = '提交成功！'
                        }
                        layer.msg(msg,{time:1000});
                        _this.modal.accountRegulateDetailAndEdit = false;
                        _this.regulatePagingMethod()
                    }else{
                        layer.msg(data.msg,{time:1000})
                    }
            })
        },
        //提交
        submitBill:function(id){
            /**
             * id 调账id
             */
            var _this = this;
            layer.alert('确定要提交吗？', {
                title: '提示信息',
                btn: ['取消', '确认'],
                btn1:function(index){
                    layer.close(index)
                },
                btn2:function(){
                    VUE_UTIL.getAxiosInstance().post("/finance/erpAccountRegulation/update",VUE_UTIL.buildPostFormData({
                        id: id,
                        status: 1,//0待提交 1 提交待审核 2 审核
                    })).then(function(response){
                        var data = response.data;
                        if(data.code == 0){
                            layer.msg('提交成功',{time:1000,success:function(){
                                _this.regulatePagingMethod()
                            }});
                        }else{
                            layer.msg(data.msg,{time:1000})
                        }
                    })
                }})
        },
        //取消调账
        cancelOff:function (id) {
            var _this=this
            layer.alert('是否确认取消该调账？', {
                title: '提示信息',
                btn: ['取消', '确认'],
                btn1:function(index){
                    layer.close(index)
                },
                btn2:function(){
                    axios.get('/finance/erpAccountRegulation/delete?id='+id).then(function (response) {
                        if(response.data.code==0){
                            layer.msg('取消调账成功', {time: 1000})
                            _this.regulatePagingMethod()
                        }else {
                            layer.msg("取消调账失败", {time: 1000})
                        }
                    })
                }
            })
        },
        //vue 验证
        validate:function(validateObj,validateParam){
            //验证-S
            var canThrough = true;   //默认通过
            for(var i in validateParam){
                if(validateParam.hasOwnProperty(i)){
                    var type = Object.prototype.toString.call(validateObj[i]).slice(8,-1);
                    if(type == 'Array' && validateObj[i].length == 0){
                        //数组判断
                        layer.msg(validateParam[i].msg,{time:1000})
                        canThrough = false;
                        break;
                    }else if(type == 'String' && validateObj[i] == ''){
                        //字符串判断
                        layer.msg(validateParam[i].msg,{time:1000})
                        canThrough  = false;
                        break;
                    }else if(type == 'Number' && validateObj[i] <0){
                        //数字判断
                        layer.msg(validateParam[i].msg,{time:1000})
                        canThrough  = false;
                        break;
                    }else if(type == 'Undefined' || type == 'Null'){
                        //无值判断
                        layer.msg(validateParam[i].msg,{time:1000})
                        canThrough  = false;
                        break;
                    }
                    //正则判断
                    if(!!validateParam[i].regExp){
                        var regExp = new RegExp(validateParam[i].regExp);
                        if(!regExp.test(validateObj[i])){
                            canThrough  = false;
                            layer.msg(validateParam[i].regExpMsg,{time:1000})
                            break;
                        }
                    }
                }
            }
            return canThrough;
            //验证-E
        },
        //保留两位小数(添加数组)
        changeRegulationMoney:function(index,val,oldVal){
            /**
             * index 要更改的数组索引
             * val 字段新值
             * oldVal 字段老值
             */
            var self = this;
            var regex = /^\-?\d+((\.)?(\d){0,2})?$/g;
            if(val == '' || val == '-'){
                return false
            }
            if(val.length > 1 && val.slice(-1) == '。'){
                layer.msg('请输入英文字符"."',{time:1000})
            }
            if(index === -1 && !regex.test(val)){
                //编辑
                self.updateStatus.regulationMoney = oldVal;
            }else if(index != -1 && !regex.test(val)){
                //批量添加
                self.batchAddAccountRegulation.accountRegulationList[index].regulationMoney = oldVal;
            }else{

            }
        },
    }
})